package com.somsoft.handjc.activity.jiancha;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;

import com.somsoft.handjc.activity.BaseGridViewActivity;
import com.somsoft.handjc.activity.R;
import com.somsoft.handjc.activity.jiancha.xuncha.ZhongHeJcActivity;
import com.somsoft.handjc.activity.jiancha.xzsp.XzspJcMainActivity;
import com.somsoft.handjc.activity.jiancha.xzzf.XzzfZhongHeJcMainActivity;
import com.somsoft.handjc.util.MyApplication;
import com.somsoft.handjc.util.Utils;

@SuppressWarnings("all")
public class JianChaActivity extends BaseGridViewActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyApplication.getInstance().addActivity(this);
		setContentView(R.layout.gridview);
		GridView gridview = (GridView) findViewById(R.id.gridview);
		Integer[] pics = {R.drawable.b1, R.drawable.b2, R.drawable.b3, R.drawable.b4,R.drawable.b5 };
		String[] titles = {"效能巡查监察","行政执法监察","行政审批监察","公共资源监察","重大项目监察"};
		super.createGridView(gridview,pics,titles);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		boolean flag = false;
		Intent it = null;
		switch (arg2) {
		case 0:
			flag = Utils.isPass(Utils.USER_LEVEL, ZhongHeJcActivity.class);
			if(flag){
				it = new Intent(JianChaActivity.this,ZhongHeJcActivity.class);
				Utils.openLoading(JianChaActivity.this);
			}else{
				Toast t = Toast.makeText(this, "对不起！你无权访问该模块！", Toast.LENGTH_SHORT);
				t.setGravity(Gravity.CENTER, 0, 0);
				t.show();
			}
			break;
		case 1:
			flag = Utils.isPass(Utils.USER_LEVEL, XzzfZhongHeJcMainActivity.class);
			if(flag){
				it = new Intent(JianChaActivity.this,XzzfZhongHeJcMainActivity.class);
			}else{
				Toast t = Toast.makeText(this, "对不起！你无权访问该模块！", Toast.LENGTH_SHORT);
				t.setGravity(Gravity.CENTER, 0, 0);
				t.show();
			}
			break;
		case 2:
			flag = Utils.isPass(Utils.USER_LEVEL, XzspJcMainActivity.class);
			if(flag){
				it = new Intent(JianChaActivity.this,XzspJcMainActivity.class);
			}else{
				Toast t = Toast.makeText(this, "对不起！你无权访问该模块！", Toast.LENGTH_SHORT);
				t.setGravity(Gravity.CENTER, 0, 0);
				t.show();
			}
			break;
		default:
			Toast t = Toast.makeText(this, "该功能开发中！", Toast.LENGTH_SHORT);
			t.setGravity(Gravity.CENTER, 0, 0);
			t.show();
			break;
		}
		if(it != null){
			startActivity(it);
		}
	}
}